package com.future.erp.basic.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.future.erp.basic.entity.BasicUser;
import com.future.erp.basic.service.BasicUserService;

@Controller
@RequestMapping("user")
public class BasicUserController {
	@Autowired
	BasicUserService basicUserService;
	
	
	@RequestMapping("login")
	public String login(@RequestParam("username") String username,
			@RequestParam("password") String password,
			HttpSession session) {
		BasicUser basicUser = new BasicUser();
		basicUser.setLoginname(username);
		basicUser.setPassword(password);
		if(0==basicUserService.queryCount(basicUser)) {
			System.out.println("登录失败");
			return "error";
		}
		session.setAttribute("existUser", username);
		return "welcome";
	}
	
	
}
